package com.dap.cms.governance.common;

import com.dap.cms.governance.po.CmsManagerPo;

import javax.servlet.http.HttpServletRequest;

/**
 * @description: 线程变量类
 * @author: Fesine
 * @createTime:2018/5/8
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2018/5/8
 */
public class RequestHolder {

    private static final ThreadLocal<CmsManagerPo> USER_HOLDER = new ThreadLocal<>();
    private static final ThreadLocal<HttpServletRequest> REQUEST_HOLDER = new ThreadLocal<>();

    public static void add(CmsManagerPo serviceUserPo){
        USER_HOLDER.set(serviceUserPo);
    }

    public static void add(HttpServletRequest request) {
        REQUEST_HOLDER.set(request);
    }

    public static CmsManagerPo getCurrentUser(){
        return USER_HOLDER.get();
    }
    public static HttpServletRequest getCurrentRequest(){
        return REQUEST_HOLDER.get();
    }

    public static void remove(){
        USER_HOLDER.remove();
        REQUEST_HOLDER.remove();
    }


}
